bitkeeper revision 1.1062.1.7 (40f24af2r5kZAs1cqmBvB4wRz47kpg)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 12 Jul 2004 08:25:22 +0000 (08:25 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Mon, 12 Jul 2004 08:25:22 +0000 (08:25 +0000)
Fix the linker scripts to always produce exactly one loadable program
segment.

xen/arch/x86/boot/mkelf32.c
xen/arch/x86/x86_32/xen.lds
xen/arch/x86/x86_64/xen.lds

index 779dab662b7451f36b9ec3fbfa5c9c02ae3b4cc6..286a61315a05763a05573b7c312d8b324bf6004d 100644 (file)
@@ -199,6 +199,13 @@ int main(int argc, char **argv)
             return 1;
         }
 
+        if ( in32_ehdr.e_phnum != 1 )
+        {
+            fprintf(stderr, "Expect precisly 1 program header; found %d.\n",
+                    (int)in32_ehdr.e_phnum);
+            return 1;
+        }
+
         (void)lseek(infd, in32_ehdr.e_phoff, SEEK_SET);
         do_read(infd, &in32_phdr, sizeof(in32_phdr));
 
@@ -218,6 +225,13 @@ int main(int argc, char **argv)
             return 1;
         }
 
+        if ( in64_ehdr.e_phnum != 1 )
+        {
+            fprintf(stderr, "Expect precisly 1 program header; found %d.\n",
+                    (int)in64_ehdr.e_phnum);
+            return 1;
+        }
+
         (void)lseek(infd, in64_ehdr.e_phoff, SEEK_SET);
         do_read(infd, &in64_phdr, sizeof(in64_phdr));
 
index 5947ebada55496752f38b03eba0a5f48f446df20..bb9f3278028de6e448cd64d30bd4c42bfe4b63f6 100644 (file)
@@ -1,9 +1,14 @@
 /* ld script to make i386 Linux kernel
- * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>;
+ * Written by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+ * Modifified for i386 Xen by Keir Fraser
  */
 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
 OUTPUT_ARCH(i386)
 ENTRY(start)
+PHDRS
+{
+  text PT_LOAD ;
+}
 SECTIONS
 {
   . = 0xFC400000 + 0x100000;
@@ -12,61 +17,61 @@ SECTIONS
        *(.text)
        *(.fixup)
        *(.gnu.warning)
-       } 0x9090
-  .text.lock : { *(.text.lock) }       /* out-of-line lock text */
+       } :text =0x9090
+  .text.lock : { *(.text.lock) } :text /* out-of-line lock text */
 
   _etext = .;                  /* End of text section */
 
-  .rodata : { *(.rodata) *(.rodata.*) }
-  .kstrtab : { *(.kstrtab) }
+  .rodata : { *(.rodata) *(.rodata.*) } :text
+  .kstrtab : { *(.kstrtab) } :text
 
   . = ALIGN(16);               /* Exception table */
   __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
+  __ex_table : { *(__ex_table) } :text
   __stop___ex_table = .;
 
   __start___ksymtab = .;       /* Kernel symbol table */
-  __ksymtab : { *(__ksymtab) }
+  __ksymtab : { *(__ksymtab) } :text
   __stop___ksymtab = .;
 
   __start___kallsyms = .;      /* All kernel symbols */
-  __kallsyms : { *(__kallsyms) }
+  __kallsyms : { *(__kallsyms) } :text
   __stop___kallsyms = .;
 
   .data : {                    /* Data */
        *(.data)
        CONSTRUCTORS
-       }
+       } :text
 
   _edata = .;                  /* End of data section */
 
   . = ALIGN(8192);             /* init_task */
-  .data.init_task : { *(.data.init_task) }
+  .data.init_task : { *(.data.init_task) } :text
 
   . = ALIGN(4096);             /* Init code and data */
   __init_begin = .;
-  .text.init : { *(.text.init) }
-  .data.init : { *(.data.init) }
+  .text.init : { *(.text.init) } :text
+  .data.init : { *(.data.init) } :text
   . = ALIGN(16);
   __setup_start = .;
-  .setup.init : { *(.setup.init) }
+  .setup.init : { *(.setup.init) } :text
   __setup_end = .;
   __initcall_start = .;
-  .initcall.init : { *(.initcall.init) }
+  .initcall.init : { *(.initcall.init) } :text
   __initcall_end = .;
   . = ALIGN(4096);
   __init_end = .;
 
   . = ALIGN(4096);
-  .data.page_aligned : { *(.data.idt) }
+  .data.page_aligned : { *(.data.idt) } :text
 
   . = ALIGN(32);
-  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
+  .data.cacheline_aligned : { *(.data.cacheline_aligned) } :text
 
   __bss_start = .;             /* BSS */
   .bss : {
        *(.bss)
-       }
+       } :text
   _end = . ;
 
   /* Sections to be discarded */
index d189a27e03b7587f4483728ac485ccdd5f8f0c1d..cdf1a6168ef030b306f4acd42fd2d74de922d540 100644 (file)
@@ -1,7 +1,12 @@
 /* Excerpts written by Martin Mares <mj@atrey.karlin.mff.cuni.cz> */
+/* Modified for x86-64 Xen by Keir Fraser */
 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(start)
+PHDRS
+{
+  text PT_LOAD ;
+}
 SECTIONS
 {
   . = 0xFFFF830000100000;
@@ -10,61 +15,61 @@ SECTIONS
        *(.text)
        *(.fixup)
        *(.gnu.warning)
-       } = 0x9090
-  .text.lock : { *(.text.lock) }       /* out-of-line lock text */
+       } :text = 0x9090
+  .text.lock : { *(.text.lock) } :text /* out-of-line lock text */
 
   _etext = .;                  /* End of text section */
 
-  .rodata : { *(.rodata) *(.rodata.*) }
-  .kstrtab : { *(.kstrtab) }
+  .rodata : { *(.rodata) *(.rodata.*) } :text
+  .kstrtab : { *(.kstrtab) } :text
 
   . = ALIGN(16);               /* Exception table */
   __start___ex_table = .;
-  __ex_table : { *(__ex_table) }
+  __ex_table : { *(__ex_table) } :text
   __stop___ex_table = .;
 
   __start___ksymtab = .;       /* Kernel symbol table */
-  __ksymtab : { *(__ksymtab) }
+  __ksymtab : { *(__ksymtab) } :text
   __stop___ksymtab = .;
 
   __start___kallsyms = .;      /* All kernel symbols */
-  __kallsyms : { *(__kallsyms) }
+  __kallsyms : { *(__kallsyms) } :text
   __stop___kallsyms = .;
 
   .data : {                    /* Data */
        *(.data)
        CONSTRUCTORS
-       }
+       } :text
 
   _edata = .;                  /* End of data section */
 
   . = ALIGN(8192);             /* init_task */
-  .data.init_task : { *(.data.init_task) }
+  .data.init_task : { *(.data.init_task) } :text
 
   . = ALIGN(4096);             /* Init code and data */
   __init_begin = .;
-  .text.init : { *(.text.init) }
-  .data.init : { *(.data.init) }
+  .text.init : { *(.text.init) } :text
+  .data.init : { *(.data.init) } :text
   . = ALIGN(16);
   __setup_start = .;
-  .setup.init : { *(.setup.init) }
+  .setup.init : { *(.setup.init) } :text
   __setup_end = .;
   __initcall_start = .;
-  .initcall.init : { *(.initcall.init) }
+  .initcall.init : { *(.initcall.init) } :text
   __initcall_end = .;
   . = ALIGN(4096);
   __init_end = .;
 
   . = ALIGN(4096);
-  .data.page_aligned : { *(.data.idt) }
+  .data.page_aligned : { *(.data.idt) } :text
 
   . = ALIGN(32);
-  .data.cacheline_aligned : { *(.data.cacheline_aligned) }
+  .data.cacheline_aligned : { *(.data.cacheline_aligned) } :text
 
   __bss_start = .;             /* BSS */
   .bss : {
        *(.bss)
-       }
+       } :text
   _end = . ;
 
   /* Sections to be discarded */